package com.yt.supplier.service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;
import javax.annotation.Resource;
import com.yt.supplier.common.config.YmlConfig;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yt.supplier.mapper.ProductCategoryMapper;
import com.yt.supplier.models.service.IProductCategoryService;
import com.yt.supplier.models.bo.ProductCategorySaveBO;
import com.yt.supplier.models.dto.ProductCategoryDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 产品分类信息控制器
 *
 * @author lizicong
 * @Date 2025-09-10 10:09:27
 */
@DubboService
@Service
public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMapper, ProductCategoryDTO> implements IProductCategoryService{

    @Resource
    private YmlConfig ymlConfig;

    @Autowired
    private ProductCategoryMapper productCategoryMapper;

    @Override
    public boolean add(ProductCategorySaveBO saveBO) {
        ProductCategoryDTO dto = new ProductCategoryDTO();
        BeanUtils.copyProperties(saveBO,dto);
        Long id = ymlConfig.getPkId();
        dto.setId(id);
        return this.insert(dto);
    }

    @Override
    public List<ProductCategoryDTO> SearchproductCategorylist(String keyword) {
        Wrapper wrapper = new EntityWrapper();
        wrapper.like("category_name",keyword);
        List<ProductCategoryDTO> productCategoryDTOlist = productCategoryMapper.selectList(wrapper);
        return productCategoryDTOlist;
    }
}
